class MENU {
    public:
        MENU();
        ~MENU();
        
        //properties
        IMAGE * background;
        int options;
        int menuChoice;
        
        //behaviors
        int ShowMainMenu();
    private:
        void SHOWCREDITS();
        void SHOWHELP();
        
}MainMenu;

int MENU::ShowMainMenu()
{   
    #define RETRO 1
    #define CLASSIC 2
    #define BOSS 3
    #define LOAD 4
    #define HELP 5
    #define CREDITS 6
    #define QUIT 7

    while(1)
    {
        //read keys
        oslReadKeys();
        
        //handle player input
        if(osl_keys->pressed.down)   {oslPlaySound(select, 2); menuChoice++;}
        else if(osl_keys->pressed.up){oslPlaySound(select, 2); menuChoice--;}
        
        //adjust menu
        if(menuChoice > options) menuChoice = 1;
        if(menuChoice < 1)       menuChoice = options;
        
        /* handle */
        if(menuChoice == RETRO){
            if(osl_keys->pressed.cross || osl_keys->pressed.start)
            {oslPlaySound(select, 2); BLOX2(RETRO); return ACTIVE;}
        }

        else if(menuChoice == CLASSIC){
            if(osl_keys->pressed.cross || osl_keys->pressed.start)
            {oslPlaySound(select, 2); BLOX2(CLASSIC); return ACTIVE;}
        }

        else if(menuChoice == BOSS){
            if(osl_keys->pressed.cross || osl_keys->pressed.start)
            {oslPlaySound(select, 2);  BLOX2(BOSS); return ACTIVE;}
        }

        else if(menuChoice == LOAD){
            if(osl_keys->pressed.cross || osl_keys->pressed.start)
            {oslPlaySound(select, 2);  return ACTIVE;}
        }
        
        else if(menuChoice == HELP){
            if(osl_keys->pressed.cross || osl_keys->pressed.start)
            {oslPlaySound(select, 2);  return ACTIVE;}
        }
        
        else if(menuChoice == CREDITS){
            if(osl_keys->pressed.cross || osl_keys->pressed.start)
            {oslPlaySound(select, 2); SHOWCREDITS(); return ACTIVE;}
        }
                    
        else if(menuChoice == QUIT){
            if(osl_keys->pressed.cross || osl_keys->pressed.start)
            {oslPlaySound(select, 2); return EXIT;}
        }
        
        oslStartDrawing();
        oslClearScreen(BLACK);
        
        oslSetFont(normal); oslIntraFontSetStyle(normal, 1.0f,WHITE,BLACK,INTRAFONT_ALIGN_LEFT); 
        if(menuChoice == RETRO){oslSetFont(bold); oslIntraFontSetStyle(bold, 1.0f,RED,BLACK,INTRAFONT_ALIGN_LEFT);}
        oslDrawString(5, 20, "RETRO");
        
        oslSetFont(normal); oslIntraFontSetStyle(normal, 1.0f,WHITE,BLACK,INTRAFONT_ALIGN_LEFT);  
        if(menuChoice == CLASSIC){oslSetFont(bold); oslIntraFontSetStyle(bold, 1.0f,RED,BLACK,INTRAFONT_ALIGN_LEFT);}
        oslDrawString(5, 50, "CLASSIC");
        
        oslSetFont(normal); oslIntraFontSetStyle(normal, 1.0f,WHITE,BLACK,INTRAFONT_ALIGN_LEFT); 
        if(menuChoice == BOSS){oslSetFont(bold); oslIntraFontSetStyle(bold, 1.0f,RED,BLACK,INTRAFONT_ALIGN_LEFT);}
        oslDrawString(5, 80, "BOSS");
        
        oslSetFont(normal); oslIntraFontSetStyle(normal, 1.0f,WHITE,BLACK,INTRAFONT_ALIGN_LEFT); 
        if(menuChoice == LOAD){oslSetFont(bold); oslIntraFontSetStyle(bold, 1.0f,RED,BLACK,INTRAFONT_ALIGN_LEFT);}
        oslDrawString(5, 110, "Load");
        
        oslSetFont(normal); oslIntraFontSetStyle(normal, 1.0f,WHITE,BLACK,INTRAFONT_ALIGN_LEFT); 
        if(menuChoice == HELP){oslSetFont(bold); oslIntraFontSetStyle(bold, 1.0f,RED,BLACK,INTRAFONT_ALIGN_LEFT);}
        oslDrawString(5, 140, "Help");
        
        oslSetFont(normal); oslIntraFontSetStyle(normal, 1.0f,WHITE,BLACK,INTRAFONT_ALIGN_LEFT); 
        if(menuChoice == CREDITS){oslSetFont(bold); oslIntraFontSetStyle(bold, 1.0f,RED,BLACK,INTRAFONT_ALIGN_LEFT);}
        oslDrawString(5, 170, "Credits");
        
        oslSetFont(normal); oslIntraFontSetStyle(normal, 1.0f,WHITE,BLACK,INTRAFONT_ALIGN_LEFT); 
        if(menuChoice == QUIT){oslSetFont(bold); oslIntraFontSetStyle(bold, 1.0f,RED,BLACK,INTRAFONT_ALIGN_LEFT);}
        oslDrawString(5, 200, "Quit");
        
        oslEndDrawing();
        oslSyncFrame();
    }
    
    return ACTIVE;   
}

void MENU::SHOWHELP()
{
    OSL_IMAGE * help = oslLoadImageFilePNG((char*)"img/data/help.png", OSL_IN_RAM, OSL_PF_5551);
    
    while(1)
    {
        oslReadKeys();
        if(osl_keys->pressed.circle){oslPlaySound(select, 2); break;}
        
        oslStartDrawing();
        oslClearScreen(BLACK);
        oslDrawImage(help);
        
        oslSetFont(bold);
        oslDrawString(5, 15, "Help");
        
        oslEndDrawing();
        oslSyncFrame();
    }
    
    return;
}

void MENU::SHOWCREDITS()
{
    oslSetFont(normal);
    oslSetTextColor(WHITE);
    
    while(1)
    {
    	oslReadKeys();
    	if(osl_keys->pressed.circle) {oslPlaySound(select, 2); break;}
    	  
        oslStartDrawing();
        oslClearScreen(BLACK);
          
        oslDrawString(5, 15, "Credits: Blox 2 betav5");
          
        oslDrawString(5, 35, "Developed by V@ughn...Kos it's good");
        
        oslDrawString(5, 75, "Tools used:"); 
          
        oslDrawString(5, 95, "-Dev-C++ 4.9.9.2");
        oslDrawString(5, 115, "-sfxr generator");
        oslDrawString(5, 135, "-oslib + gu of pspsdk");
          
        oslEndDrawing();
        oslSyncFrame();
    }
    
    return;
}

MENU::MENU(){
    if(background != NULL){oslDeleteImage(background); background = NULL;}
    menuChoice = 1;
    options = 1;
    
    return;
}

MENU::~MENU(){
    if(background != NULL){oslDeleteImage(background); background = NULL;}
    
    return;
}
